<template>
  <view class="card">
    <navigator class="card-more" hover-class="none" v-if="isMore">
      <image class="image" src="@/assets/images/classify1.jpg" mode="scaleToFill" />
      <view class="mask">
        <uniIcons type="more-filled" size="38" color="#fff" />
        <text>{{ moreText }}</text>
      </view>
    </navigator>
    <navigator :url="url" class="link" hover-class="none" v-else>
      <view class="tag">{{ tagContext }}</view>
      <view class="title">{{ title }}</view>
      <image class="image" :src="picUrl" mode="scaleToFill" />
    </navigator>
  </view>
</template>

<script setup lang="ts">
  import uniIcons from '@dcloudio/uni-ui/lib/uni-icons/uni-icons.vue';
  // import { getImageURL } from '@/utils';
  defineOptions({
    name: 'Card'
  });

  defineProps<{
    url: string;
    isMore?: boolean;
    moreText: string;
    tagContext: string;
    title: string;
    picUrl: string;
  }>();
</script>

<style lang="scss" scoped>
  .card {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 342rpx;
    border-radius: 10rpx;

    .link,
    .card-more {
      height: 100%;
    }

    .card-more {
      position: relative;
      .mask {
        position: absolute;
        inset: 0;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        color: #fff;
        background-color: rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(15px);
      }
    }

    .title {
      position: absolute;
      bottom: 0;
      left: 0;
      right: 0;
      height: 70rpx;
      line-height: 70rpx;
      color: #fff;
      z-index: 2;
      text-align: center;
      background-color: rgba(0, 0, 0, 0.2);
      backdrop-filter: blur(5px);
    }

    .tag {
      position: absolute;
      top: 0;
      left: 0;
      z-index: 2;
      padding: 4rpx 16rpx;
      background-color: #f59a80;
      color: #fff;
      font-size: 24rpx;
      transform: scale(0.8);
      transform-origin: 0 0;
      border-radius: 20rpx 0;
    }

    .image {
      width: 100%;
      height: 100%;
    }
  }
</style>
